﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Medical.Business;
using Medical.Entity;

/// <summary>
/// 答疑页面
/// </summary>
public partial class webadmin_FeedBackInfo : AdminPage
{
    /// <summary>
    /// ID
    /// </summary>
    protected int nID;
    protected void Page_Load(object sender, EventArgs e)
    {
        //获取ID
        nID = Convert.ToInt32(Common.GetQueryValue("id", 0));
        if (!Page.IsPostBack)
        {
            InitData();
        }
    }

    protected void InitData()
    {
        BisFeedBack bisFeedBack = new BisFeedBack();
        DataTable dtFaq = bisFeedBack.GetList(nID);
        rptFeedBack.DataSource = dtFaq;
        rptFeedBack.DataBind();
    }
    /// <summary>
    /// 回复
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string strInfo = txtReInfo.Text.Trim();
        if (string.IsNullOrEmpty(strInfo))
        {
            Until.Alert("请输入回复内容！");
            return;
        }
        FeedBackInfo Info = new FeedBackInfo();
        Info.ReType = 1;
        Info.Info = strInfo;
        Info.ParentID = nID;
        BisFeedBack bisFeedBack = new BisFeedBack();
        bool bResult = bisFeedBack.Insert(Info);
        if (bResult)
        {
            Info.ID = nID;
            bisFeedBack.Update(Info);
        }

        Until.Alert(bResult ? "提交成功！" : "提交失败！");
        InitData();
    }

    /// <summary>
    /// 分类列表绑定
    /// </summary>
    /// <param name="source"></param>
    /// <param name="e"></param>
    protected void rptFeedBack_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        int nID = Convert.ToInt32(e.CommandArgument);
        bool bResult = new BisFeedBack().Delete(nID);
        Until.Alert(bResult ? "删除成功！" : "删除失败！");
        InitData();
    }
}